package com.xian.d3_calendar;

import java.util.Calendar;
import java.util.Date;

public class CalendarDemo1 {
    public static void main(String[] args) {
        //1、拿到系统此刻日历对象
        Calendar cal = Calendar.getInstance();
        System.out.println(cal);
        /**
         *     [time=1696238145822,areFieldsSet=true,
         *          areAllFieldsSet=true,lenient=true,
         *          zone=sun.util.calendar.ZoneInfo
         *          [id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,
         *          transitions=31,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,
         *          YEAR=2023,
         *          MONTH=9,
         *          WEEK_OF_YEAR=40,WEEK_OF_MONTH=1,
         *          DAY_OF_MONTH=2,DAY_OF_YEAR=275,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,
         *          AM_PM=1,HOUR=5,HOUR_OF_DAY=17,MINUTE=15,
         *          SECOND=45,MILLISECOND=822,ZONE_OFFSET=28800000,DST_OFFSET=0]
         */


        //2、获取日历的信息public int get(int field):取日期中的某个字段信息。
        int year = cal.get(Calendar.YEAR);
        System.out.println(year);
        int month = cal.get(Calendar.MONTH) + 1;
        System.out.println(month);
        int day = cal.get(Calendar.DAY_OF_YEAR);
        System.out.println(day);


        //3、public void set(int field ,int value):修改日历的某个字段信息。
        //cal.set(Calendar.HOUR, 12);  //一般不会修改
        //System.out.println(cal);

        //4.public void add(int field ,int amount):为某个字段增加/减少指定的值请问64天后是什么时间
        //请问64天后是什么时间
        cal.add(Calendar.DAY_OF_YEAR,64);
        cal.add(Calendar.MINUTE,30);

        //5.public final Date getTime():拿到此刻日期对象。
        Date time = cal.getTime();
        System.out.println(time);

        //6.public long getTimeInMillis():拿到此刻时间毫秒值
        long time1 = cal.getTimeInMillis();
        System.out.println(time1);
    }
}
